<?php

namespace Home\Controller;

use Think\Controller;
use \Model\EntityModel;
use \Model\BookModel;

use \Model\SkillShareModel;
use Common\Common\UserGlobal;  //公共类


//预约
class BookController extends Controller {

    //提交订单
    public function order_submit() {
//	dump($_GET);
	if($_POST) {
//	    $this->assign("a","123");
	    $_POST['order_book_user_account'] = $_SESSION['user_account'];
	    $_POST['order_book_time'] = date('Y-m-d H:i:s', time());
	    D('order')->add($_POST);
	    dump($_POST);exit;
	    
//	    $this->redirect("Book/book_successful");
	}else{
	    $skill_id = $_GET['skill_id'];
	    //dump($skill_id);
	    $book_model = new BookModel();
	    //exit;
	    $user_account = $_SESSION['user_account'];
	    $info = $book_model ->get_data_order_submit($skill_id);
	    $address = $book_model ->get_data_user_address($user_account);
	    $info[0]['order_number'] = "T".date("Ymdhis");
	    //dump($info[0]);exit;
	    $this ->assign("info", $info[0]);
	    $this ->assign("address", $address[0]);
	    $this->display();
	}
	
    }
    
    //选择地址
    public function select_address() {
	$this->display();
    }
    
    //修改地址
    public function change_address() {
	$this->display();
    }
    
    //预约成功
    public function book_successful($order_number) {
	
	$info = D("order")->where('order_number="'.$order_number.'"')->select();
//	dump($info);exit;
	$this->assign('info', $info[0]);
//	$this->assign("a","123");
	$this->display();
    }
    
}